Skip to content

Replace wmi queries with win32 api calls#116

Merged
narph merged 10 commits intoelastic:masterfrom
narph:fix-process-get-args-gosigar
Apr 24, 2019
Merged

Replace wmi queries with win32 api calls#116
narph merged 10 commits intoelastic:masterfrom
narph:fix-process-get-args-gosigar

Conversation

@narph
Copy link

@narph narph commented Apr 18, 2019

Fixes elastic/beats#11840

Alternative to disable config option here elastic/beats#3249

Addresses high CPU load on windows

Fixes elastic/beats#11840

Addresses high CPU load on windows
@narph narph requested a review from andrewkroh April 18, 2019 15:54
@narph narph self-assigned this Apr 18, 2019
@narph narph requested a review from ruflin April 19, 2019 07:05
@narph narph added the review label Apr 19, 2019
sigar_windows.go Outdated
args = nil
}
}
var process = Win32_Process{CommandLine: &args[0]}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can remove the Win32_Process struct completely.

sigar_windows.go Outdated
if err != nil {
return nil
}
var args []string
Copy link
Member

@andrewkroh andrewkroh Apr 19, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of creating a variable, what about just using self.List directly?

@narph narph requested a review from andrewkroh April 23, 2019 10:28
Copy link
Member

@andrewkroh andrewkroh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@narph narph changed the title Remove wmi queries with win32 api calls Replace wmi queries with win32 api calls Apr 23, 2019
CHANGELOG.md Outdated
### Fixed
- Added missing runtime import for FreeBSD. #104
- Handle nil command line in Windows processes. #110
- Replaced the WMI queries with win32 apis due to high CPU usage. #11840
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this go under unrealeased?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all good now

@narph narph merged commit ab1e753 into elastic:master Apr 24, 2019
rubionic added a commit to rubionic/gosigar that referenced this pull request Oct 3, 2025
This PR combines two critical fixes:

1. macOS Fix (from cloudfoundry#77):
   - Updates sigar_darwin.go to use unix.SysctlUint64() for reading sysctl values
   - Fixes checkptr violations in Go 1.22+ when accessing uint64 values

2. Windows Fix (from elastic#116):
   - Implements ProcArgs.Get() using Win32 API instead of returning ErrNotImplemented
   - Replaces WMI queries with direct ReadProcessMemory and NtQueryInformationProcess calls
   - Adds helper functions: GetUserProcessParams, ReadProcessUnicodeString, ByteSliceToStringSlice
   - Adds syscall bindings for ReadProcessMemory and GetTickCount64

Fixes rkoster/rubionic-workspace#38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Metricbeat]System/process metricset - WmiPrvSE.exe seems to utilize more CPU on v 7.0.0

3 participants